package com.app.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.app.service.IComplaintService;
import com.app.util.Result;
import com.github.binarywang.wxpay.service.ComplaintService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.bytebuddy.asm.Advice;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/adminComplaint")
@Api(tags = "admin投诉建议接口")
public class AdminComplaintController {
    @Autowired
    private IComplaintService complaintService;


    @ApiOperation(value = "投诉意见——分页列表查询")
    @GetMapping("/list")
    public Result<Object> list(Integer page, Integer limit,String keyword) {
        return complaintService.complaintList(page,limit,keyword);
    }


    @ApiOperation(value = "投诉意见详情")
    @GetMapping("/getById")
    public Result<Object> getById(Integer id) {
        return Result.success(complaintService.getById(id));
    }

    @ApiOperation(value = "删除投诉意见")
    @GetMapping("/deleteById")
    public Result<Object> deleteById(Integer id) {
        if (!StpUtil.hasPermission("admin:complaints:delete")){
            return Result.error("您暂无此权限");
        }
        return complaintService.deleteById(id);
    }
}
